package edu.hawaii.duedates.webapp;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.apache.wicket.util.tester.WicketTester;
import edu.hawaii.duedates.datastore.DueDatesConfig;
import edu.hawaii.duedates.datastore.User;

/**
 * Tests the DueDatesSession class.
 * @author Daniel Arakaki, Jeho Jung, Arthur Shum, Daniel Tian.
 *
 */
public class TestDueDatesSession {
  
  /**
   * Test the session methods.
   */
  @Test
  public void testResults() {
    WicketTester tester = new WicketTester();
    tester.setupRequestAndResponse();
    DueDatesSession testSession = new DueDatesSession(tester.getWicketRequest());
    
    assertFalse("isLoggedIn false", testSession.isLoggedIn());
    testSession.setIsLoggedIn();
    assertTrue("isLoggedIn true", testSession.isLoggedIn());
    
    User user = new User("name", "email", "password");
    testSession.setUser(user);
    assertSame("Test User", user, testSession.getUser());
    
    String smtpServer = "testServer";
    testSession.setSmtpServer(smtpServer);
    assertSame("Test smtpServer", smtpServer,testSession.getSmtpServer());
    
    DueDatesConfig config = new DueDatesConfig();
    testSession.setDueDatesConfig(config);
    assertSame("Test DueDatesConfig", config, testSession.getDueDatesConfig());
    
    assertNotNull("Test new task", testSession.getNewTask());
    assertSame("Test task", testSession.getNewTask(), testSession.getTask());
    
    testSession.setAlertsEnabled(true);
    assertTrue("alertsEnabled true", testSession.alertsEnabled());
    testSession.setAlertsEnabled(false);
    assertFalse("alertsEnabled false", testSession.alertsEnabled());
    
  } 
  
}
